﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.ComponentModel;
using System.Data.Linq.Mapping;

namespace StudyEnglish.Model
{
    [Table(Name = "User")]
    public class AppUser : INotifyPropertyChanged, INotifyPropertyChanging
    {
        private int _ID;
        [Column(IsPrimaryKey = true, IsDbGenerated = true, DbType = "INT NOT NULL Identity", CanBeNull = false, AutoSync = AutoSync.OnInsert)]
        public int ID
        {
            get { return _ID; }
            set
            {
                if (_ID != value)
                {
                    NotifyPropertyChanging("ID");
                    _ID = value;
                    NotifyPropertyChanged("ID");
                }
            }
        }

        private string _username;
        [Column]
        public string username
        {
            get { return _username; }
            set
            {
                if (_username != value)
                {
                    NotifyPropertyChanging("username");
                    _username = value;
                    NotifyPropertyChanged("username");
                }
            }
        }

        private string _password;
        [Column]
        public string password
        {
            get { return _password; }
            set
            {
                if (_password != value)
                {
                    NotifyPropertyChanging("password");
                    _password = value;
                    NotifyPropertyChanged("password");
                }
            }
        }

        private int _CountWord;
        [Column]
        public int CountWord
        {
            get { return _CountWord; }
            set
            {
                if (_CountWord != value)
                {
                    NotifyPropertyChanging("CountWord");
                    _CountWord = value;
                    NotifyPropertyChanged("CountWord");
                }
            }
        }
        #region INotifyPropertyChanged Members

        public event PropertyChangedEventHandler PropertyChanged;
        private void NotifyPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }

        #endregion

        #region INotifyPropertyChanging Members

        public event PropertyChangingEventHandler PropertyChanging;
        private void NotifyPropertyChanging(string propertyName)
        {
            if (PropertyChanging != null)
                PropertyChanging(this, new PropertyChangingEventArgs(propertyName));
        }

        #endregion
   
    }
}
